import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import axios from "axios";
import http from "./api/http.js";
import vueSwiper from "vue-awesome-swiper";
import "swiper/dist/css/swiper.css";
import Vant from "vant";
import "vant/lib/index.css";
import reset from "./assets/css/reset.css";
import "./assets/css/iconfont.css";
import "./assets/css/iconfont2.css";
import './assets/css3/iconfont.css';
import "./assets/css/resetui.scss";
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import $ from 'jquery';
window.$ = $;

Vue.prototype.$axios = axios;
Vue.prototype.$http = http;
Vue.use(ElementUI);
Vue.use(vueSwiper);
Vue.use(Vant);
Vue.use(reset);
Vue.config.productionTip = false;

router.beforeEach((to, from, next) => {
  if (
    store.state.token ||
    to.name == "login" ||
    to.name == "phoneLogin" ||
    to.name == "password" ||
    to.name == "phoneyanzheng"
  ) {
    next();
    store.commit("NavShow", { top: to.meta.isTopNav, btm: to.meta.isBtnNav });
  } else {
    next({
      path: "/login"
    });
  }
});

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
